/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package core;

/**
 *
 * @author Victor
 */
public enum Actions {
    REMOVE_CODE("Remove code","Remove all occurences of the given code.","Code to remove",null),
    ENCAPSULATE_TAGS("Encapsulate tags","Encapsulate a serie of tags with a given tag.","Tag which serie needs to be surrounded","Surrounding tag"),
    REPLACE_IMAGE_PATH("Replace image path","Replace all occurences of the path by an other path.","Old image path","New image path"),
    REPLACE_CODE("Replace code","Replace all occurences of the code by an other code.","Old code","New code"),
    CLEAN_COMMENT("Clean comments","Clean all comments."),
    SUPPRESS_ATTRIBUTE_IN_STYLE_ATTRIBUTE("Suppress attribute in style attribute","Remove attribute in the style attribute in any tag.","Attribute which needs to be removed",null),
    CORRECT_TITLES("Correct titles","Correct titles.","Name of the class that indicates a title",null),
    REMOVE_TAG("Remove tag","Remove every tag & closure tag","Tag to remove",null),
    REMOVE_ATTRIBUTE_FROM_TAG("Remove attribute from tag","Remove attribute from tag","Tag which we need to remove the attribute from","Attribute to remove"),
    REMOVE_ATTRIBUTE("Remove attribute","Remove attribute","Attribute to remove from all tags",null),
    CORRECT_TAG("Correct tags","Correct tags by their class","Tag which will replace all the tags which bears the class","Class which indicates a special tag");

    private String name;
    private String help;
    private final String parameter2Desc;
    private final String parameter1Desc;

    Actions(String name,String help){
        this(name,help,null,null);
    }
    Actions(String name,String help,String parameter1Desc,String parameter2Desc){
        this.name=name;
        this.help=help;
        this.parameter2Desc = parameter2Desc;
        this.parameter1Desc = parameter1Desc;
    }
    Actions(String name,String help,String parameter1Desc){
        this(name,help,parameter1Desc,null);
    }
    /**
     *
     * @return The description (null if there's no description).
     */
    public String getParameter2Description(){
        return (parameter2Desc!=null)?parameter2Desc:"";
    }
    public String getParameter1Description(){
        return (parameter1Desc!=null)?parameter1Desc:"";
    }
    public boolean hasParameter1(){
        return parameter1Desc!=null;
    }
    public boolean hasParameter2(){
        return parameter2Desc!=null;
    }
    @Override
    public String toString(){
        return name;
    }
    public String getName(){
        return name;
    }
    public String getHelp(){
        return help;
    }
    /**
     *
     * @param s The String we want to get the actions of. Isn't case sensitive.
     * @return
     */
    public static Actions stringToAction(String s){

        for(Actions a :Actions.values()){
            if(a.getName().toLowerCase().equals(s.toLowerCase())){
                return a;
            }
        }
        return null;
    }
    public static String getActionDone(Setting s){
        switch(s.getType()){
            case ENCAPSULATE_TAGS:
                return ("Encapsulate "+s.getParam1()+" tags with "+s.getParam2());
            case REMOVE_CODE:
                return ("Remove the code "+s.getParam1());
            case REPLACE_CODE:
                return ("Replace the code "+s.getParam1()+" by "+s.getParam2());
            case REPLACE_IMAGE_PATH:
                return ("Replace the code "+s.getParam1()+" by "+s.getParam2());

            case CLEAN_COMMENT:
                return ("Clean all comments");
            case SUPPRESS_ATTRIBUTE_IN_STYLE_ATTRIBUTE:
                return ("Remove "+s.getParam1()+" attribute from style attribute");
            case CORRECT_TITLES:
                if(s.getParam1()!=null){
                    return ("Titles to replace set to "+s.getParam1());
                }
                else return ("Correct titles");
            case REMOVE_TAG:
                return ("Remove <"+s.getParam1()+"> tags");
            case REMOVE_ATTRIBUTE_FROM_TAG:
                return ("Remove "+s.getParam2()+" from <"+s.getParam1()+"> tags");
            case REMOVE_ATTRIBUTE:
                return ("Remove "+s.getParam1()+" from all tags");
            case CORRECT_TAG:
                return ("Correct "+s.getParam1()+" tags");
            default:
                return ("Error in Settings file.");
        }
    }
    
}
